package com.abvnet.project.water.api.web;

import com.abvnet.framework.web.controller.BaseController;
import com.abvnet.framework.web.domain.AjaxResult;
import com.abvnet.project.water.project.domain.ProjectWater;
import com.abvnet.project.water.project.service.IProjectWaterService;
import com.abvnet.project.water.sewage.service.ISewageIndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/project/water")
public class ApiProjectWaterController extends BaseController {

    @Autowired
    private IProjectWaterService projectWaterService;

    @Autowired
    private ISewageIndexService sewageIndexService;

    @GetMapping("/get")
    public AjaxResult get(@RequestParam("projectId") Long projectId) {
        AjaxResult ar = AjaxResult.success(projectWaterService.selectProjectWaterByProjectId(projectId));
        ar.put("indexList", sewageIndexService.selectSewageIndexList(null));
        return ar;
    }

    @PostMapping("/edit")
    public AjaxResult editSave(ProjectWater projectWater) {
        return toAjax(projectWaterService.updateProjectWater(projectWater));
    }
}
